if (!("finalizeConstruction" in ViewPU.prototype)) {
    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
import promptAction from '@ohos.promptAction';
export class EcList extends ViewPU {
    constructor(j32, k32, l32, m32 = -1, n32 = undefined, o32) {
        super(j32, l32, m32, o32);
        if (typeof n32 === "function") {
            this.paramsGenerator_ = n32;
        }
        this.sticky = StickyStyle.None;
        this.__autoLoad = new SynchedPropertySimpleOneWayPU(k32.autoLoad, this, "autoLoad");
        this.__refreshStatus = new ObservedPropertySimplePU(RefreshStatus.Inactive, this, "refreshStatus");
        this.loadingText = '加载中...';
        this.finishedText = '没有更多了~';
        this.gutter = 10;
        this.__loading = new SynchedPropertySimpleOneWayPU(k32.loading, this, "loading");
        this.__finished = new SynchedPropertySimpleOneWayPU(k32.finished, this, "finished");
        this.__isRefreshing = new SynchedPropertySimpleTwoWayPU(k32.isRefreshing, this, "isRefreshing");
        this.listContent = this.DefaultListContent;
        this.load = () => {
        };
        this.refresh = () => {
        };
        this.setInitiallyProvidedValue(k32);
        this.finalizeConstruction();
    }
    setInitiallyProvidedValue(i32) {
        if (i32.sticky !== undefined) {
            this.sticky = i32.sticky;
        }
        if (i32.autoLoad === undefined) {
            this.__autoLoad.set(true);
        }
        if (i32.refreshStatus !== undefined) {
            this.refreshStatus = i32.refreshStatus;
        }
        if (i32.loadingText !== undefined) {
            this.loadingText = i32.loadingText;
        }
        if (i32.finishedText !== undefined) {
            this.finishedText = i32.finishedText;
        }
        if (i32.gutter !== undefined) {
            this.gutter = i32.gutter;
        }
        if (i32.loading === undefined) {
            this.__loading.set(false);
        }
        if (i32.finished === undefined) {
            this.__finished.set(false);
        }
        if (i32.listContent !== undefined) {
            this.listContent = i32.listContent;
        }
        if (i32.load !== undefined) {
            this.load = i32.load;
        }
        if (i32.refresh !== undefined) {
            this.refresh = i32.refresh;
        }
    }
    updateStateVars(h32) {
        this.__autoLoad.reset(h32.autoLoad);
        this.__loading.reset(h32.loading);
        this.__finished.reset(h32.finished);
    }
    purgeVariableDependenciesOnElmtId(g32) {
        this.__autoLoad.purgeDependencyOnElmtId(g32);
        this.__refreshStatus.purgeDependencyOnElmtId(g32);
        this.__loading.purgeDependencyOnElmtId(g32);
        this.__finished.purgeDependencyOnElmtId(g32);
        this.__isRefreshing.purgeDependencyOnElmtId(g32);
    }
    aboutToBeDeleted() {
        this.__autoLoad.aboutToBeDeleted();
        this.__refreshStatus.aboutToBeDeleted();
        this.__loading.aboutToBeDeleted();
        this.__finished.aboutToBeDeleted();
        this.__isRefreshing.aboutToBeDeleted();
        SubscriberManager.Get().delete(this.id__());
        this.aboutToBeDeletedInternal();
    }
    get autoLoad() {
        return this.__autoLoad.get();
    }
    set autoLoad(f32) {
        this.__autoLoad.set(f32);
    }
    get refreshStatus() {
        return this.__refreshStatus.get();
    }
    set refreshStatus(e32) {
        this.__refreshStatus.set(e32);
    }
    get loading() {
        return this.__loading.get();
    }
    set loading(d32) {
        this.__loading.set(d32);
    }
    get finished() {
        return this.__finished.get();
    }
    set finished(c32) {
        this.__finished.set(c32);
    }
    get isRefreshing() {
        return this.__isRefreshing.get();
    }
    set isRefreshing(b32) {
        this.__isRefreshing.set(b32);
    }
    DefaultListContent(l31 = null) {
        {
            const m31 = (z31, a32) => {
                ViewStackProcessor.StartGetAccessRecordingFor(z31);
                n31(z31, a32);
                if (!a32) {
                    ListItem.pop();
                }
                ViewStackProcessor.StopGetAccessRecording();
            };
            const n31 = (x31, y31) => {
                ListItem.create(o31, true);
            };
            const o31 = (s31, t31) => {
                m31(s31, t31);
                this.observeComponentCreation2((v31, w31) => {
                    Text.create('列表...');
                }, Text);
                Text.pop();
                ListItem.pop();
            };
            this.observeComponentCreation2(n31, ListItem);
            ListItem.pop();
        }
    }
    LoadingBuilder(l30 = null) {
        this.observeComponentCreation2((n30, o30) => {
            If.create();
            if (this.finished) {
                this.ifElseBranchUpdateFunction(0, () => {
                    this.observeComponentCreation2((j31, k31) => {
                        Row.create();
                        Row.width('100%');
                        Row.height(50);
                        Row.justifyContent(FlexAlign.Center);
                    }, Row);
                    this.observeComponentCreation2((h31, i31) => {
                        Text.create(this.finishedText);
                        Text.fontColor({ "id": -1, "type": 10001, params: ['app.color.yk_mid_99'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
                        Text.fontSize({ "id": -1, "type": 10002, params: ['app.float.yk_normal_font_size'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
                    }, Text);
                    Text.pop();
                    Row.pop();
                });
            }
            else {
                this.ifElseBranchUpdateFunction(1, () => {
                    this.observeComponentCreation2((r30, s30) => {
                        If.create();
                        if (this.loading) {
                            this.ifElseBranchUpdateFunction(0, () => {
                                this.observeComponentCreation2((c31, d31) => {
                                    Row.create();
                                    Row.width('100%');
                                    Row.height(50);
                                    Row.justifyContent(FlexAlign.Center);
                                }, Row);
                                this.observeComponentCreation2((a31, b31) => {
                                    LoadingProgress.create();
                                    LoadingProgress.width(24);
                                    LoadingProgress.margin({ right: 5 });
                                }, LoadingProgress);
                                this.observeComponentCreation2((y30, z30) => {
                                    Text.create(this.loadingText);
                                    Text.fontColor({ "id": -1, "type": 10001, params: ['app.color.yk_mid_59'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
                                    Text.fontSize({ "id": -1, "type": 10002, params: ['app.float.yk_normal_font_size'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
                                }, Text);
                                Text.pop();
                                Row.pop();
                            });
                        }
                        else {
                            this.ifElseBranchUpdateFunction(1, () => {
                            });
                        }
                    }, If);
                    If.pop();
                });
            }
        }, If);
        If.pop();
    }
    refreshStatusTxt() {
        switch (this.refreshStatus) {
            case RefreshStatus.Drag:
                return '下拉刷新';
            case RefreshStatus.OverDrag:
                return '释放刷新';
            case RefreshStatus.Refresh:
                return '刷新中...';
            default:
                return '';
        }
    }
    RefreshBuilder(b30 = null) {
        this.observeComponentCreation2((j30, k30) => {
            Row.create();
            Row.margin(30);
        }, Row);
        this.observeComponentCreation2((h30, i30) => {
            Progress.create({ value: 0, total: 100, type: ProgressType.Ring });
            Progress.width(20);
            Progress.color({ "id": -1, "type": 10001, params: ['app.color.yk_main_color'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
            Progress.style({
                strokeWidth: 20,
                status: this.refreshStatus === RefreshStatus.Refresh ? ProgressStatus.LOADING : ProgressStatus.PROGRESSING
            });
            Progress.margin({ right: 10 });
        }, Progress);
        this.observeComponentCreation2((f30, g30) => {
            Text.create(this.refreshStatusTxt());
            Text.fontColor({ "id": -1, "type": 10001, params: ['app.color.yk_mid_59'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
            Text.fontSize({ "id": -1, "type": 10002, params: ['app.float.yk_normal_font_size'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" });
        }, Text);
        Text.pop();
        Row.pop();
    }
    initialRender() {
        this.observeComponentCreation2((z29, a30) => {
            Column.create();
            Column.width('100%');
            Column.layoutWeight(1);
        }, Column);
        this.observeComponentCreation2((t29, u29) => {
            Refresh.create({ refreshing: { value: this.isRefreshing, changeEvent: y29 => { this.isRefreshing = y29; } }, builder: this.RefreshBuilder.bind(this) });
            Refresh.onStateChange((x29) => {
                this.refreshStatus = x29;
                console.info('Refresh onStatueChange state is ' + x29);
                if (x29 === RefreshStatus.Done) {
                    promptAction.showToast({
                        message: '刷新成功'
                    });
                }
            });
            Refresh.onRefreshing(() => {
                this.refresh();
            });
            Refresh.width('100%');
            Refresh.height('100%');
        }, Refresh);
        this.observeComponentCreation2((q29, r29) => {
            List.create({ space: this.gutter });
            List.width('100%');
            List.height('100%');
            List.scrollBar(BarState.Off);
            List.sticky(this.sticky);
            List.onReachEnd(() => {
                this.autoLoad && this.load();
            });
        }, List);
        this.listContent.bind(this)();
        this.observeComponentCreation2((a29, b29) => {
            If.create();
            if (this.refreshStatus !== RefreshStatus.Refresh) {
                this.ifElseBranchUpdateFunction(0, () => {
                    {
                        const e29 = (o29, p29) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(o29);
                            f29(o29, p29);
                            if (!p29) {
                                ListItem.pop();
                            }
                            ViewStackProcessor.StopGetAccessRecording();
                        };
                        const f29 = (m29, n29) => {
                            ListItem.create(g29, true);
                        };
                        const g29 = (k29, l29) => {
                            e29(k29, l29);
                            this.LoadingBuilder.bind(this)();
                            ListItem.pop();
                        };
                        this.observeComponentCreation2(f29, ListItem);
                        ListItem.pop();
                    }
                });
            }
            else {
                this.ifElseBranchUpdateFunction(1, () => {
                });
            }
        }, If);
        If.pop();
        List.pop();
        Refresh.pop();
        Column.pop();
    }
    rerender() {
        this.updateDirtyElements();
    }
}
